package com.efast.dmom.mgmt.service.les.impl;

import java.util.Date;
import java.util.List;

import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.dmom.mgmt.dao.les.TwAdjDetailsDao;
import com.efast.dmom.mgmt.entity.les.TwAdjDetails;
import com.efast.dmom.mgmt.entity.master.TmBasDloc;
import com.efast.dmom.mgmt.entity.master.TmBasLoc;
import com.efast.dmom.mgmt.service.les.TwAdjDetailsService;
import com.efast.dmom.mgmt.utils.Assist;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TwAdjDetailsServiceImpl implements TwAdjDetailsService {

	@Autowired
	private TwAdjDetailsDao twAdjDetailsDao;

	@Override
	public int insertNonEmptyTwAdjDetails(TwAdjDetails value) {
		List<TwAdjDetails> listTwAdjDetails = twAdjDetailsDao.selectTwAdjDetails(
				new Assist(Assist.andEq("tw_adj_details.tw_adj_header_id", value.getTwAdjHeaderId())));
		value.setLineNo(listTwAdjDetails.size() + 1); // 调整单行号
		value.setLineStatus("0"); // 订单行状态 单据状态0新单1发布2完成3关闭4部分调整
		value.setMarkStatus(1);
		value.setCreateTime(new Date());
		value.setCreateUser(SpringWebUtils.getRequestUser());
		value.setCompanyCode(SpringWebUtils.getRequestCompany());
		return twAdjDetailsDao.insertNonEmptyTwAdjDetails(value);
	}

	/**
	 * TODO 简单描述该方法的实现功能（可选）.
	 * @see com.efast.emfg.remote.les.TwAdjDetailsService#queryLocByDloc(int)
	 */
	@Override
	public List<TmBasLoc> queryLocByDloc(int i) {
		return twAdjDetailsDao.queryLocByDloc(i);
	}

	/**
	 * TODO 简单描述该方法的实现功能（可选）.
	 * @see com.efast.emfg.remote.les.TwAdjDetailsService#queryDlocByWh(int)
	 */
	@Override
	public List<TmBasDloc> queryDlocByWh(int i) {
		return twAdjDetailsDao.queryDlocByWh(i);
	}

	@Override
	public long getTwAdjDetailsRowCount(Assist assist) {
		return twAdjDetailsDao.getTwAdjDetailsRowCount(assist);
	}

	@Override
	public List<TwAdjDetails> selectTwAdjDetails(Assist assist) {
		return twAdjDetailsDao.selectTwAdjDetails(assist);
	}

	@Override
	public TwAdjDetails selectTwAdjDetailsByObj(TwAdjDetails obj) {
		return twAdjDetailsDao.selectTwAdjDetailsByObj(obj);
	}

	@Override
	public TwAdjDetails selectTwAdjDetailsById(Integer id) {
		return twAdjDetailsDao.selectTwAdjDetailsById(id);
	}

	@Override
	public int insertTwAdjDetails(TwAdjDetails value) {
		return twAdjDetailsDao.insertTwAdjDetails(value);
	}

	@Override
	public int insertTwAdjDetailsByBatch(List<TwAdjDetails> value) {
		return twAdjDetailsDao.insertTwAdjDetailsByBatch(value);
	}

	@Override
	public int deleteTwAdjDetailsById(Integer id) {
		return twAdjDetailsDao.deleteTwAdjDetailsById(id);
	}

	@Override
	public int deleteTwAdjDetails(Assist assist) {
		return twAdjDetailsDao.deleteTwAdjDetails(assist);
	}

	@Override
	public int updateTwAdjDetailsById(TwAdjDetails enti) {
		return twAdjDetailsDao.updateTwAdjDetailsById(enti);
	}

	@Override
	public int updateTwAdjDetails(TwAdjDetails value, Assist assist) {
		return twAdjDetailsDao.updateTwAdjDetails(value, assist);
	}

	@Override
	public int updateNonEmptyTwAdjDetailsById(TwAdjDetails enti) {
		return twAdjDetailsDao.updateNonEmptyTwAdjDetailsById(enti);
	}

	@Override
	public int updateNonEmptyTwAdjDetails(TwAdjDetails value, Assist assist) {
		return twAdjDetailsDao.updateNonEmptyTwAdjDetails(value, assist);
	}

	public TwAdjDetailsDao getTwAdjDetailsDao() {
		return this.twAdjDetailsDao;
	}

	public void setTwAdjDetailsDao(TwAdjDetailsDao twAdjDetailsDao) {
		this.twAdjDetailsDao = twAdjDetailsDao;
	}

}